from langchain_community.tools.ainetwork import app
# pip install langchain
# pip install langchain-zhipu
# import os
# import getpass

from langchain_zhipu import ChatZhipuAI
from langchain_core.prompts import ChatPromptTemplate

from langchain_core.output_parsers import StrOutputParser
from langchain.schema import (AIMessage, HumanMessage, SystemMessage)

# os.environ['ZHIPUAI_API_KEY'] = getpass.getpass("ZHIPUAI API Key:")
output_parser = StrOutputParser()

# llm = ChatZhipuAI(model="glm-4")
llm = ChatZhipuAI(api_key="d3708ee404327e207b2f003775e06908.X3dgRCxbkyDfEIbh"
                  , model="glm-4")
llm.temperature = 0.01# 温度设置为0，结果随机性 ghbnm

prompt = ChatPromptTemplate.from_messages([
    ("system", "不要假设或猜测，尽可能简短且友好的回复客户，等待客户提问"),
    ("assistant", "你是吉利汽车员工福利商城的客服人员.你每天工作8个小时，早9:00到晚6:00。"),
    ("user", "{input}")
])
# @app.post("/chat")
# async def chat(request):
chain = prompt | llm | output_parser
print(chain.invoke({"input": "你是谁？你晚上9点会休息么？"}))
